﻿package mortal.game.resource.tableConfig
{
    import Message.DB.Tables.*;
    import com.gengine.resource.*;
    import flash.utils.*;
    import mortal.game.view.common.*;

    public class HalidomConfig extends Object
    {
        private var _halidomDic:Dictionary;
        private var _seriesDic:Dictionary;
        private var _typeObj:Object;
        private static var _instance:HalidomConfig;

        public function HalidomConfig()
        {
            this._typeObj = {};
            this.initHalidom();
            this.initHalidomSeries();
            return;
        }// end function

        private function initHalidom() : void
        {
            var _loc_2:Object = null;
            var _loc_3:THalidomConfig = null;
            this._halidomDic = new Dictionary();
            var _loc_1:* = ConfigManager.instance.getJSONByFileName("t_halidom_config.json");
            for each (_loc_2 in _loc_1)
            {
                
                _loc_3 = new THalidomConfig();
                ClassTypesUtil.copyValue(_loc_3, _loc_2);
                this._halidomDic[_loc_3.halidomId + "_" + _loc_3.level] = _loc_3;
            }
            return;
        }// end function

        private function initHalidomSeries() : void
        {
            var _loc_2:Object = null;
            var _loc_3:THalidomSeriesConfig = null;
            this._seriesDic = new Dictionary();
            var _loc_1:* = ConfigManager.instance.getJSONByFileName("t_halidom_series_config.json");
            for each (_loc_2 in _loc_1)
            {
                
                _loc_3 = new THalidomSeriesConfig();
                ClassTypesUtil.copyValue(_loc_3, _loc_2);
                this._seriesDic[_loc_3.series + "_" + _loc_3.orderId] = _loc_3;
                this._typeObj[_loc_3.halidomId] = _loc_3;
            }
            return;
        }// end function

        public function get seriesData() : Array
        {
            var _loc_2:THalidomSeriesConfig = null;
            var _loc_1:Array = [];
            for each (_loc_2 in this._seriesDic)
            {
                
                _loc_1.push(_loc_2);
            }
            _loc_1.sortOn("halidomId", Array.NUMERIC);
            return _loc_1;
        }// end function

        public function getHalidomListBySeries(param1:int) : Array
        {
            var _loc_3:THalidomSeriesConfig = null;
            var _loc_2:Array = [];
            var _loc_4:int = 1;
            while (_loc_4 < int.MAX_VALUE)
            {
                
                _loc_3 = this.getSeriesItem(param1, _loc_4);
                if (!_loc_3)
                {
                    break;
                }
                _loc_2.push(_loc_3);
                _loc_4++;
            }
            return _loc_2;
        }// end function

        public function getItem(param1:int, param2:int) : THalidomConfig
        {
            return this._halidomDic[param1 + "_" + param2] as THalidomConfig;
        }// end function

        public function getSeriesItem(param1:int, param2:int) : THalidomSeriesConfig
        {
            return this._seriesDic[param1 + "_" + param2];
        }// end function

        public function getTypeItem(param1:int) : THalidomSeriesConfig
        {
            return this._typeObj[param1];
        }// end function

        public static function get instance() : HalidomConfig
        {
            if (!_instance)
            {
                _instance = new HalidomConfig;
            }
            return _instance;
        }// end function

    }
}
